<?php


namespace apps\marriage\core\model;


use think\facade\Db;
use vm\com\BaseModel;

class SubscribeMessageTemplate extends BaseModel
{
    const TYPE_ONCE = 2;    // 一次性通知
    const TYPE_PERMANENT = 3; //永久性通知

    public function deleteEarliestTemplateIdByOpenid($openid, $templateId, $type)
    {
        $sql = "DELETE FROM " . $this->getTable() . " WHERE openid=:openid AND template_id=:template_id AND `type`=:type ORDER BY add_time ASC LIMIT 1";
        $bind = [
            'openid' => $openid,
            'template_id' => $templateId,
            'type' => $type
        ];
        return Db::execute($sql, $bind);
    }
}